package java学习.实训.day06.program;

/**
 * **************
 * 项目名称: 蓝桥杯 <br/>
 * 文件名称:  <br/>
 * 文件描述: 这里添加您的类文件描述，说明当前文件要包含的功能。 <br/>
 * 文件创建：刘世锦 <br/>
 * 创建时间: 2022/6/14 <br/>
 *
 * @version v1.0 <br/>
 * @update [序号][日期YYYY-MM-DD][更改人姓名][变更描述]<br/>
 * *************
 */
public class Chessboard {
    public  static final  int ROW = 15;
    public  static final  int COLUMN = 15;

    public   static   Piece[][] pieceArr = new Piece[ROW][COLUMN];

    public Piece[][] getPieceArr() {
        return pieceArr;
    }

//    public void setPieceArr(Piece[][] pieceArr) {
//        this.pieceArr = pieceArr;
//    }

    String chars = "┌ ┬ ┐ ├ ┼ ┤ ┼ └ ┴ ┘ ┌ ─ ┬ ─ ┐";
    //落子
    public boolean fallPiece(Piece piece){
        boolean flag = true;
        int x = piece.getX();
        int y = piece.getY();
        if (pieceArr[x][y].getSymbol().equals(Main.WHITE) ||pieceArr[x][y].getSymbol().equals(Main.BLACK) ){ // 有棋子
            return flag;
        }
        pieceArr[x][y]= piece;
        flag = false;
        return flag;

    }


   public   void initChessBord(){
//       pieceArr[0][0] = new Piece(0,0,"┌");
//       pieceArr[0][14] = new Piece(0,14,"┐");
//       pieceArr[14][0] = new Piece(14,0,"└");
//       pieceArr[14][14] = new Piece(14,14,"┘");


       for (int i = 0; i < pieceArr.length; i++) {
           for (int j = 0; j < pieceArr[i].length; j++) {
                   if(i==0 ){
                       if (j==0){
                           pieceArr[0][0] = new Piece(0,0,"┌");
                       }else if (j==pieceArr[i].length-1){
                           pieceArr[0][14] = new Piece(0,14,"┐");
                       }else
                       pieceArr[0][j]  = new Piece(0,j,"┬");
                   }
                  else if (i==pieceArr.length-1){  // ┌ ┬ ┐├  ┼ ┤ └ ┴ ┘─│

                       if (j==0){
                           pieceArr[14][0] = new Piece(14,0,"└");
                       }else if (j==pieceArr[i].length-1){
                           pieceArr[14][14] = new Piece(14,14,"┘");
                       } else
                       pieceArr[pieceArr.length-1][j]  = new Piece(pieceArr.length-1,j,"┴");
                   }
                   else if (j==0){

                       pieceArr[i][0]  = new Piece(i,0,"├");
                   }
                   else if (j==pieceArr[i].length-1){
                       pieceArr[i][j]  = new Piece(i,j,"┤");
                   }else {

                   pieceArr[i][j]  = new Piece(i,j,"┼");

               }

           }

       }
////当你要下子的时候
//       Piece pp = new Piece(8,8,'●');●o
//       pieceArr[8][8] = pp;
   }


    public void printChessBord(){
        char[] nums1= {'1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
        char[] nums = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E'};

        System.out.print("   ");
        for (char num : nums) {
            System.out.print (num+"  ");
        }
        System.out.println();
       for (int i = 0; i < pieceArr.length; i++) {
           System.out.print(nums[i]+"  ");
           for (int j = 0; j < pieceArr[i].length; j++) {
               Piece piece = pieceArr[i][j];
                if (j!=pieceArr[i].length-1){
                    System.out.print(pieceArr[i][j].getSymbol()+"──");
                }else {
                    System.out.print(pieceArr[i][j].getSymbol() );

                }
           }
           System.out.println();
       }
   }


}
